package com.ccs.loas;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class EditLOA {

	public void edit_maximum_amount(WebDriver driver) throws Exception{
		
		WebElement amount = driver.findElement(By.xpath("//input[@id='forMaxlimit']"));
		empty_amount(driver, amount);
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		less_amount(driver, amount);
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		amount.clear();
		amount.sendKeys("10500");
		
	}
	public void edit_pf_amount(WebDriver driver) throws Exception{
		
		WebElement pf = driver.findElement(By.xpath("//input[@id='forMaxPf']"));
		empty_pf(driver, pf);
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		less_pf(driver, pf);
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		pf.clear();
		pf.sendKeys("2000");
		
	}
	public void empty_amount(WebDriver driver, WebElement amount){
		
		amount.clear();
		driver.findElement(By.xpath("//input[@value='Generate LOA']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//span[contains(.,'Covered Amount is a required field ')]"));
		
	}
	public void less_amount(WebDriver driver, WebElement amount){
		
		amount.clear();
		amount.sendKeys("1");
		driver.findElement(By.xpath("//input[@value='Generate LOA']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//span[contains(.,'Covered Amount cannot be less than the previous amount')]"));
		
	}
	public void empty_pf(WebDriver driver, WebElement pf){
		
		pf.clear();
		driver.findElement(By.xpath("//input[@value='Generate LOA']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//span[contains(.,'Maximum PF Amount field cannot be empty or zero (0) when Include PF is checked ')]"));
		
	}
	public void less_pf(WebDriver driver, WebElement pf){
		
		pf.clear();
		pf.sendKeys("1");
		driver.findElement(By.xpath("//input[@value='Generate LOA']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//span[contains(.,'Maximum Pf Amount cannot be less than the previous amount')]"));
		
	}
	
}
